package com.yand.thinkingInJava.thinkingInJava21.ShareResource;

public class SynchronizedEventGeneraor extends IntGenerator {
    private int currentEventValue = 0;

    @Override
    public synchronized int next() {

        ++currentEventValue;
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        ++currentEventValue;

        return currentEventValue;
    }


    public  static void main(String [] args){
        EventChecker.test(new SynchronizedEventGeneraor());
    }
}
